<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of carts
 *
 * @author sonUIT
 */
class Query extends CI_Controller {

    public function __construct() {
        parent::__construct();
  $this->load->model("SANPHAM");
    }
  public function load_page($namepage, $data) {
        if ($this->session->userdata('is_logged_in')) {
            $data['link'] = '';
            $data['link_logout'] = base_url() . 'index.php/welcome/dangxuat';
            $data['log_out'] = 'ĐĂNG XUẤT';
            $data['text_before'] = 'TÀI KHOẢN';
            $data['text_after'] = $this->session->userdata('email');
            $data['include'] = 'member.php';
            $this->load->view($namepage, $data);
        } else {
            $data['link'] = base_url() . 'index.php/welcome/dangky';
            $data['link_logout'] = '';
            $data['log_out'] = '';
            $data['text_before'] = 'ĐĂNG NHẬP';
            $data['text_after'] = 'ĐĂNG KÝ';
            $data['include'] = 'login.php';
            if ($namepage === 'trangchu' || $namepage === 'dangky') {
                $this->load->view($namepage, $data);
            }
            else
                $this->load->view('error', $data);
        }
    }
 
    public function index() {
        $sp= new Sanpham();
        $q= $this->input->get('q');
      $data['query']= $q;
        $data['data_nho'] = $sp->getListObject("*","mota like '%$q%' or tensp  like '%$q%'","sldamua DESC");
       $this->load_page('query',$data);        
    }


}

?>